package com.example.easeimpro;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.example.easeimpro.model.bean.Model;
import com.example.easeimpro.utils.SpUtils;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMOptions;
import com.hyphenate.easeui.EaseIM;

public class BaseApplication extends Application {
    public static Context context;
    private static final String TAG = "BaseApplication";
    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        EMOptions options = new EMOptions();
        //初始化SDK
        if(EaseIM.getInstance().init(context, options)){
            //在做打包混淆时，关闭 debug 模式，避免消耗不必要的资源
            EMClient.getInstance().setDebugMode(true);

            if(SpUtils.getInstance().getFriendBox()){
               // options.setAcceptInvitationAlways(true);
                Log.e(TAG, "onCreate: " );
            }else {
                options.setAcceptInvitationAlways(false);
                Log.e(TAG, "onCreate: false" );
            }


            //EaseIM 初始化成功之后再调用注册消息监听的代码 ...
        }
        Model.getInstance().init(this);

        EaseIM.getInstance().init(context, options);
    }
    //获取全局上下文对象
    public static Context getGlobalApplication(){
        return context;
    }

}
